< previous page page_377 next page >

Page 377
Tutorial 9
Inside a DLL File:
Exploring the DumpInfo Program
One of the most common problems you will face when using API functions is figuring out which DLL exports a function that you want to use. The reason this is challenging is that the Microsoft documentation does not actually list the DLL name for a function, only the import library that C programs would use to import the function. Unfortunately, the import library name does not always match the DLL name. Not only that, but it is sometimes difficult to know for sure if a function has separate ANSI and Unicode entry points.
Microsoft does provide a program named DumpBin with Visual Studio, which allows you to obtain a list of exported functions for a DLL, but it can take a long time to search through all of the DLLs for a particular function.
Even before starting on this book, I wanted to provide an automatic search utility that would take a function name and search through all of the DLLs in your system directory for the function, optionally checking for both the ANSI and Unicode variations of the function name. Ultimately I ended up writing a program that could read the export table for a DLL file. This involved understanding the specification for the Portable Executable file format (the file format used for DLLs), interpreting the structures and constants that are used with this file format, and converting them to Visual Basic. These are exactly the kinds of tasks that this book is designed to teach VB programmers to accomplish on their own, so it seemed that this utility could actually perform double service, both as a utility and as a case history.
Using DumpInfo
The DumpInfo program performs two distinct functions. First, it has the ability to list all of the exported functions for a specified DLL. The Exports command button on the main form brings up a dialog box that allows you to select a single DLL to examine. The exports for that DLL are displayed in the list box, as shown

 
< previous page page_377 next page >